# Importing Data
CANADA <- read_excel("C:/users/Biniam/Desktop/Documents/Academic/Thesis/Analysis Folder/Excel Files/Steel/TSA.xlsx",sheet = "Sheet1", range = "G1:G239")

# Checking the Imported Data
View(CANADA)
# Creating Time Series Data
CANADA_ts <- ts(CANADA, start=c(2000,1), end=c(2019,09), frequency=12)
# Viewing and Checking the Created Time Series Data
CANADA_ts
sum(is.na(CANADA_ts))
library(forecast)
CANADA_ts <- tsclean(CANADA_ts)
CANADA_ts

# Identification: Plotting the Time Series Data
plot(CANADA_ts)

# Estimating the appropriate model
CANADA_ts_model <- auto.arima(CANADA_ts)
CANADA_ts_model

# Forecasting
options(max.print=1000000)
CANADA_ts_forecast <- forecast (CANADA_ts_model, level=c(95), h=255)
plot(CANADA_ts_forecast)
CANADA_ts_forecast             

# Exporting
write.table(CANADA_ts_forecast, file="/users/Biniam/Desktop/Documents/Academic/Thesis/Result Folder/TSA Results/Excel Files/From R/Steel/CANADA_TSA.csv", sep=",")
